// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   Datum.java

package com.xml.export;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.Vector;

// Referenced classes of package com.xml.export:
//			DataBaseInfo

public class Datum
{

	DataBaseInfo dbif;
	ResultSetMetaData rsmd;
	ResultSet resultset;
	ArrayList ids;
	ArrayList columnnames;
	Vector contents;

	public Datum(String dbname, String tablename, String condition)
	{
		dbif = null;
		rsmd = null;
		resultset = null;
		ids = new ArrayList();
		columnnames = new ArrayList();
		contents = new Vector();
		dbif = new DataBaseInfo(dbname, tablename, condition);
	}

	public ArrayList getColumnName()
		throws Exception
	{
		try
		{
			if (dbif.rs == null)
				throw new Exception("please fill in table name");
			rsmd = dbif.rs.getMetaData();
			for (int i = 1; i <= rsmd.getColumnCount(); i++)
				columnnames.add(rsmd.getColumnName(i));

		}
		catch (Exception ex)
		{
			ex.printStackTrace();
			return null;
		}
		return columnnames;
	}

	public ArrayList getColumnId()
		throws Exception
	{
		try
		{
			if (dbif.rs == null)
				throw new Exception("please fill in table name");
			for (; dbif.rs.next(); ids.add(dbif.rs.getString("id")));
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
			return null;
		}
		return ids;
	}

	public Vector getContents()
		throws Exception
	{
		try
		{
			if (dbif.rs == null)
				throw new Exception("please fill in table name");
			rsmd = dbif.rs.getMetaData();
			while (dbif.rs.next()) 
			{
				for (int j = 1; j <= rsmd.getColumnCount(); j++)
					contents.addElement(dbif.rs.getObject(j));

			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
			return null;
		}
		return contents;
	}
}
